const Generator = require('yeoman-generator');

module.exports = class extends Generator {
  prompting() {
    return this.prompt([{
      type: 'input',
      name: 'name',
      message: 'Project name',
      default: this.appname,
    }])
    .then(answers => {
      this.answers = answers;
    })
  }
  writing() {
    const templates = [
      'public/favicon.ico',
      'public/index.html',
      'src/App.vue',
      'src/main.js',
      'src/router/index.js',
      'src/components/HelloWorld.vue',
      'src/store/index.js',
      'src/views/About.vue',
      'src/views/Home.vue',
      'tests/unit/example.spec.js',
      '.browserslistrc',
      '.eslintrc.js',
      '.gitignore',
      'babel.config.js',
      'jest.config.js',
      'package.json',
      'README.md',
      'plopfile.js',
      'plop-templates/component.hbs',
      'plop-templates/test.hbs',
    ];

    templates.forEach(item => {
      this.fs.copyTpl(
        this.templatePath(item),
        this.destinationPath(item),
        this.answers,
      );
    })
  }
}